package com;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import com.utils.PropertyUtils;

public class Starter{
	public static Long startTime=null;
	public static Long current=null;
	public static void main(String[] args) {
		new Thread(new WriteTime()).start();
		new Timer().schedule(new TimerTask() {
			@Override
			public void run() {
				try {
					String deadlineStr = PropertyUtils.getProperty("conf","deadline");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
					Date deadline = sdf.parse(deadlineStr);
					current = new Date().getTime();
					long differ = deadline.getTime()-new Date().getTime();
					differ = differ/(1000*60);
					if(startTime == null){
						startTime = differ;
					}
					current = differ;
					System.out.println(differ+" minutes left");
					
					
					
				} catch (Exception e) {
					e.printStackTrace();
					System.out.println("an error occured");
				}
			}
		}, 0,1000*60);
	}
}
